package cn.xfdzx.android.apps.shop.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.bean.CategoryAllBeen;

public class MarketTopRecyerAdapter extends BaseQuickAdapter<CategoryAllBeen.DataBean, BaseViewHolder> {

    int p = 0;

    public MarketTopRecyerAdapter() {
        super(R.layout.adapter_top_market_recyer);
    }

    /**
     *  设置默认选择颜色
     * @param p
     */
    public void setColor(int p) {
        this.p = p;
        notifyDataSetChanged();
    }

    @Override
    protected void convert(BaseViewHolder helper, CategoryAllBeen.DataBean item) {

        helper.setText(R.id.tv_main_type, item.getName());
        Glide.with(mContext).load(item.getPic()).into((ImageView) helper.getView(R.id.iv_main_type));

        TextView tv_view = helper.getView(R.id.tv_main_type);
        if (helper.getLayoutPosition() == p) {
            tv_view.setTextColor(mContext.getResources().getColor(R.color.colorPrimary));
        } else {
            tv_view.setTextColor(mContext.getResources().getColor(R.color.color_333333));
        }
    }
}
